<!DOCTYPE html>

<%= render :partial => 'layouts/version.html.erb' %>

<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
		<title><%= content_for?(:title) ? yield(:title) : "Snorby #{Snorby::VERSION}" %></title>
		
		<meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta name="description" content="Snorby - All About Simplicity" />
    <link rel="icon" href="<%= Snorby::CONFIG[:baseuri] %>/favicon.png" type="image/png" />

		<% @severities ||= Severity.all %>

		<script type="text/javascript">
			<% @severities.each do |sev| %>
				var sev<%= sev.sig_id %>_bg_color = '<%= sev.bg_color %>';
      <% end %>

      var baseuri = "<%= Snorby::CONFIG[:baseuri] %>"; 
      var current_user = <%= @current_user.to_json(
        :only => [
          :email,
          :name,
          :sign_in_count,
          :current_sign_in_ip,
          :last_sign_in_ip,
          :id,
          :admin
        ]
      ).html_safe %>;
		</script>

		<%= csrf_meta_tag %>

		<%= include_stylesheets :snorby, :media => 'all' %>
    <%= include_javascripts :snorby %>

    <% if @current_user %>
      <script type="text/javascript" charset="utf-8">
        Snorby.current_user = current_user;
        Snorby.current_user.avatar = "<%= json_escape @current_user.avatar %>";
        Snorby.current_user.timezone = "<%= json_escape Time.zone.now.strftime('%Z') %>";
        Snorby.current_user.timezone_offset = "<%= json_escape Time.zone.utc_offset %>";
        Snorby.current_user.timezone_offset_hour = "<%= json_escape Time.zone.now.strftime('%z') %>";
        Snorby.event_notifications = <%= Setting.event_notifications? %>;
        </script>
    <% end %>


		<%= yield(:header) %>

		<style type="text/css">
			<%- @severities.each do |sev| -%>
        ul.table li div.small span.severity.sev<%= sev.sig_id %>,
        span.severity.sev<%= sev.sig_id %>{
					background-color: <%= sev.bg_color %>;
					color: <%= sev.text_color %>;
				}
			<%- end -%>
		</style>

  </head>
  
	<body>
		
		<%= render :partial => 'layouts/header.html.erb' %>

    <div id="wrapper">
      <%= render :partial => 'layouts/content.html.erb' %>		
    </div>

		<%= render :partial => 'layouts/footer.html.erb' %>
		
		<%- flash.each do |type, message| -%>

      <script type="text/javascript" charset="utf-8">
        flash_message.push({type: "<%= type %>", message: "<%= message %>"}); flash();
      </script>

    <%- end -%>
		
    <%= yield(:footer) %>

    <%= render :partial => 'layouts/notify' %>

    <script type="text/javascript" charset="utf-8">
      <% if Setting.event_notifications? %>
        monitor_events(false);
      <% else %>
        if (window.location.pathname === baseuri + "/events") {
          monitor_events(true);
        };
      <% end %>
    </script>

  </body> 
</html> 
